package
{
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.utils.Dictionary;
	import flash.display.Graphics;
public class ColorTool extends Tool
{
	protected var target:Object;
	protected var addPoint:Object;
	protected var targetLine:Object;
	public function ColorTool()
	{
		super();
		this.keyCode=67;
	}
	
	override public function down():void{
		var p:Object=canvas.getClosePoint();
		if(p){
			target=p;
		}else{
			var p2:Object=canvas.mousePoint();
			addPoint=new PointObj();
			addPoint.x=p2.x;
			addPoint.y=p2.y;
			addPoint.isColor=true;
			
			addPoint.id=canvas.getNewId();
			canvas.addColor(addPoint);
		}
	}
	
	override public function move():void{
		if(target){
			var p:Object=canvas.mousePoint();
			target.x=p.x;
			target.y=p.y;
		}
	}
	
	override public function up():void{
		if(target){
			target=null;
		}
	}
	
	override public function drawPoints(points:Collection,point_pen:Graphics):void{
		//draw points 
		var itr:Iterator=new Iterator(points.toArray());
		var p:Item=canvas.getClosePoint();
		var point:Object;
		point_pen.clear();
		point_pen.lineStyle(1,0x000000,1);
		while(itr.hasNext()){
			point=itr.next();
			if(point.isColor){
				point_pen.drawRect(point.x-3,point.y-3,6,6);
				if(p!=null && p.id==point.id){
					point_pen.beginFill(0x000000,1);
					point_pen.drawRect(point.x-3,point.y-3,6,6);
					point_pen.endFill();
				}
			}
		}
	}
	
}

}

